home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / DatabaseAccess.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  15.2 KB  |  433 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        DatabaseAccess.h
  3.  
  4.      Contains:    Database Access Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1989-1999, 1995-1997, 1999 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __DATABASEACCESS__
  18. #define __DATABASEACCESS__
  19.  
  20. #ifndef __RESOURCES__
  21.     #include <Resources.h>
  22. #endif
  23.  
  24.  
  25.  
  26.  
  27. #if PRAGMA_ONCE
  28. #pragma once
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_IMPORT
  36. #pragma import on
  37. #endif
  38.  
  39. #if PRAGMA_STRUCT_ALIGN
  40.     #pragma options align=mac68k
  41. #elif PRAGMA_STRUCT_PACKPUSH
  42.     #pragma pack(push, 2)
  43. #elif PRAGMA_STRUCT_PACK
  44.     #pragma pack(2)
  45. #endif
  46.  
  47. /* data type codes */
  48. enum {
  49.     typeNone                    = FOUR_CHAR_CODE('none'),
  50.     typeDate                    = FOUR_CHAR_CODE('date'),
  51.     typeTime                    = FOUR_CHAR_CODE('time'),
  52.     typeTimeStamp                = FOUR_CHAR_CODE('tims'),
  53.     typeDecimal                    = FOUR_CHAR_CODE('deci'),
  54.     typeMoney                    = FOUR_CHAR_CODE('mone'),
  55.     typeVChar                    = FOUR_CHAR_CODE('vcha'),
  56.     typeVBin                    = FOUR_CHAR_CODE('vbin'),
  57.     typeLChar                    = FOUR_CHAR_CODE('lcha'),
  58.     typeLBin                    = FOUR_CHAR_CODE('lbin'),
  59.     typeDiscard                    = FOUR_CHAR_CODE('disc'),        /* "dummy" types for DBResultsToText */
  60.     typeUnknown                    = FOUR_CHAR_CODE('unkn'),
  61.     typeColBreak                = FOUR_CHAR_CODE('colb'),
  62.     typeRowBreak                = FOUR_CHAR_CODE('rowb'),        /* pass this in to DBGetItem for any data type */
  63.     typeAnyType                    = 0
  64. };
  65.  
  66. /* infinite timeout value for DBGetItem */
  67. enum {
  68.                                                                 /* messages for status functions for DBStartQuery */
  69.     kDBUpdateWind                = 0,
  70.     kDBAboutToInit                = 1,
  71.     kDBInitComplete                = 2,
  72.     kDBSendComplete                = 3,
  73.     kDBExecComplete                = 4,
  74.     kDBStartQueryComplete        = 5
  75. };
  76.  
  77. enum {
  78.                                                                 /* messages for status functions for DBGetQueryResults */
  79.     kDBGetItemComplete            = 6,
  80.     kDBGetQueryResultsComplete    = 7,
  81.     kDBWaitForever                = -1
  82. };
  83.  
  84. enum {
  85.                                                                 /*  flags for DBGetItem  */
  86.     kDBLastColFlag                = 0x0001,
  87.     kDBNullFlag                    = 0x0004
  88. };
  89.  
  90. typedef OSType                             DBType;
  91. typedef struct DBAsyncParamBlockRec     DBAsyncParamBlockRec;
  92. typedef DBAsyncParamBlockRec *            DBAsyncParmBlkPtr;
  93. typedef CALLBACK_API( void , DBCompletionProcPtr )(DBAsyncParmBlkPtr pb);
  94. /*
  95.     WARNING: DBCompletionProcPtr uses register based parameters under classic 68k
  96.              and cannot be written in a high-level language without 
  97.              the help of mixed mode or assembly glue.
  98. */
  99. typedef REGISTER_UPP_TYPE(DBCompletionProcPtr)                     DBCompletionUPP;
  100. /* structure for asynchronous parameter block */
  101.  
  102. struct DBAsyncParamBlockRec {
  103.     DBCompletionUPP                 completionProc;                /* pointer to completion routine */
  104.     OSErr                             result;                        /* result of call */
  105.     long                             userRef;                    /* for application's use */
  106.     long                             ddevRef;                    /* for ddev's use */
  107.     long                             reserved;                    /* for internal use */
  108. };
  109.  
  110. /* structure for resource list in QueryRecord */
  111.  
  112. struct ResListElem {
  113.     ResType                         theType;                    /* resource type */
  114.     short                             id;                            /* resource id */
  115. };
  116. typedef struct ResListElem                ResListElem;
  117.  
  118. typedef ResListElem *                    ResListPtr;
  119. typedef ResListPtr *                    ResListHandle;
  120. /* structure for query list in QueryRecord */
  121. typedef Handle                             QueryArray[256];
  122. typedef Handle *                        QueryListPtr;
  123. typedef QueryListPtr *                    QueryListHandle;
  124.  
  125. struct QueryRecord {
  126.     short                             version;                    /* version */
  127.     short                             id;                            /* id of 'qrsc' this came from */
  128.     Handle                             queryProc;                    /* handle to query def proc */
  129.     Str63                             ddevName;                    /* ddev name */
  130.     Str255                             host;                        /* host name */
  131.     Str255                             user;                        /* user name */
  132.     Str255                             password;                    /* password */
  133.     Str255                             connStr;                    /* connection string */
  134.     short                             currQuery;                    /* index of current query */
  135.     short                             numQueries;                    /* number of queries in list */
  136.     QueryListHandle                 queryList;                    /* handle to array of handles to text */
  137.     short                             numRes;                        /* number of resources in list */
  138.     ResListHandle                     resList;                    /* handle to array of resource list elements */
  139.     Handle                             dataHandle;                    /* for use by query def proc */
  140.     long                             refCon;                        /* for use by application */
  141. };
  142. typedef struct QueryRecord                QueryRecord;
  143.  
  144. typedef QueryRecord *                    QueryPtr;
  145. typedef QueryPtr *                        QueryHandle;
  146. /* structure of column types array in ResultsRecord */
  147. typedef DBType                             ColTypesArray[256];
  148. typedef Handle                             ColTypesHandle;
  149. /* structure for column info in ResultsRecord */
  150.  
  151. struct DBColInfoRecord {
  152.     short                             len;
  153.     short                             places;
  154.     short                             flags;
  155. };
  156. typedef struct DBColInfoRecord            DBColInfoRecord;
  157.  
  158. typedef DBColInfoRecord                 ColInfoArray[256];
  159. typedef Handle                             ColInfoHandle;
  160. /* structure of results returned by DBGetResults */
  161.  
  162. struct ResultsRecord {
  163.     short                             numRows;                    /* number of rows in result */
  164.     short                             numCols;                    /* number of columns per row */
  165.     ColTypesHandle                     colTypes;                    /* data type array */
  166.     Handle                             colData;                    /* actual results */
  167.     ColInfoHandle                     colInfo;                    /* DBColInfoRecord array */
  168. };
  169. typedef struct ResultsRecord            ResultsRecord;
  170. enum {
  171.                                                                 /* messages sent to a 'ddev'*/
  172.     kDBInit                        = 0,
  173.     kDBEnd                        = 1,
  174.     kDBGetConnInfo                = 2,
  175.     kDBGetSessionNum            = 3,
  176.     kDBSend                        = 4,
  177.     kDBSendItem                    = 5,
  178.     kDBExec                        = 6,
  179.     kDBState                    = 7,
  180.     kDBGetErr                    = 8,
  181.     kDBBreak                    = 9,
  182.     kDBGetItem                    = 10,
  183.     kDBUngetItem                = 11,
  184.     kDBKill                        = 12,
  185.     kDBOpen                        = 100,
  186.     kDBClose                    = 101,
  187.     kDBIdle                        = 102
  188. };
  189.  
  190. typedef CALLBACK_API( OSErr , DBQueryDefProcPtr )(long *sessID, QueryHandle query);
  191. typedef CALLBACK_API( Boolean , DBStatusProcPtr )(short message, OSErr result, short dataLen, short dataPlaces, short dataFlags, DBType dataType, Ptr dataPtr);
  192. typedef CALLBACK_API( OSErr , DBResultHandlerProcPtr )(DBType dataType, short theLen, short thePlaces, short theFlags, Ptr theData, Handle theText);
  193. typedef STACK_UPP_TYPE(DBQueryDefProcPtr)                         DBQueryDefUPP;
  194. typedef STACK_UPP_TYPE(DBStatusProcPtr)                         DBStatusUPP;
  195. typedef STACK_UPP_TYPE(DBResultHandlerProcPtr)                     DBResultHandlerUPP;
  196. #if OPAQUE_UPP_TYPES
  197.     EXTERN_API(DBCompletionUPP)
  198.     NewDBCompletionUPP               (DBCompletionProcPtr        userRoutine);
  199.  
  200.     EXTERN_API(DBQueryDefUPP)
  201.     NewDBQueryDefUPP               (DBQueryDefProcPtr        userRoutine);
  202.  
  203.     EXTERN_API(DBStatusUPP)
  204.     NewDBStatusUPP                   (DBStatusProcPtr            userRoutine);
  205.  
  206.     EXTERN_API(DBResultHandlerUPP)
  207.     NewDBResultHandlerUPP           (DBResultHandlerProcPtr    userRoutine);
  208.  
  209.     EXTERN_API(void)
  210.     DisposeDBCompletionUPP           (DBCompletionUPP            userUPP);
  211.  
  212.     EXTERN_API(void)
  213.     DisposeDBQueryDefUPP           (DBQueryDefUPP            userUPP);
  214.  
  215.     EXTERN_API(void)
  216.     DisposeDBStatusUPP               (DBStatusUPP                userUPP);
  217.  
  218.     EXTERN_API(void)
  219.     DisposeDBResultHandlerUPP       (DBResultHandlerUPP        userUPP);
  220.  
  221.     EXTERN_API(void)
  222.     InvokeDBCompletionUPP           (DBAsyncParmBlkPtr        pb,
  223.                                     DBCompletionUPP            userUPP);
  224.  
  225.     EXTERN_API(OSErr)
  226.     InvokeDBQueryDefUPP               (long *                    sessID,
  227.                                     QueryHandle                query,
  228.                                     DBQueryDefUPP            userUPP);
  229.  
  230.     EXTERN_API(Boolean)
  231.     InvokeDBStatusUPP               (short                    message,
  232.                                     OSErr                    result,
  233.                                     short                    dataLen,
  234.                                     short                    dataPlaces,
  235.                                     short                    dataFlags,
  236.                                     DBType                    dataType,
  237.                                     Ptr                        dataPtr,
  238.                                     DBStatusUPP                userUPP);
  239.  
  240.     EXTERN_API(OSErr)
  241.     InvokeDBResultHandlerUPP       (DBType                    dataType,
  242.                                     short                    theLen,
  243.                                     short                    thePlaces,
  244.                                     short                    theFlags,
  245.                                     Ptr                        theData,
  246.                                     Handle                    theText,
  247.                                     DBResultHandlerUPP        userUPP);
  248.  
  249. #else
  250.     enum { uppDBCompletionProcInfo = 0x0000B802 };                     /* register no_return_value Func(4_bytes:A1) */
  251.     enum { uppDBQueryDefProcInfo = 0x000003E0 };                     /* pascal 2_bytes Func(4_bytes, 4_bytes) */
  252.     enum { uppDBStatusProcInfo = 0x000FAA90 };                         /* pascal 1_byte Func(2_bytes, 2_bytes, 2_bytes, 2_bytes, 2_bytes, 4_bytes, 4_bytes) */
  253.     enum { uppDBResultHandlerProcInfo = 0x0003EAE0 };                 /* pascal 2_bytes Func(4_bytes, 2_bytes, 2_bytes, 2_bytes, 4_bytes, 4_bytes) */
  254.     #define NewDBCompletionUPP(userRoutine)                         (DBCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppDBCompletionProcInfo, GetCurrentArchitecture())
  255.     #define NewDBQueryDefUPP(userRoutine)                             (DBQueryDefUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppDBQueryDefProcInfo, GetCurrentArchitecture())
  256.     #define NewDBStatusUPP(userRoutine)                             (DBStatusUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppDBStatusProcInfo, GetCurrentArchitecture())
  257.     #define NewDBResultHandlerUPP(userRoutine)                         (DBResultHandlerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppDBResultHandlerProcInfo, GetCurrentArchitecture())
  258.     #define DisposeDBCompletionUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  259.     #define DisposeDBQueryDefUPP(userUPP)                             DisposeRoutineDescriptor(userUPP)
  260.     #define DisposeDBStatusUPP(userUPP)                             DisposeRoutineDescriptor(userUPP)
  261.     #define DisposeDBResultHandlerUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  262.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  263.     #pragma parameter InvokeDBCompletionUPP(__A1, __A0)
  264.     void InvokeDBCompletionUPP(DBAsyncParmBlkPtr pb, DBCompletionUPP userUPP) = 0x4E90;
  265.     #else
  266.         #define InvokeDBCompletionUPP(pb, userUPP)                         CALL_ONE_PARAMETER_UPP((userUPP), uppDBCompletionProcInfo, (pb))
  267.     #endif
  268.     #define InvokeDBQueryDefUPP(sessID, query, userUPP)             (OSErr)CALL_TWO_PARAMETER_UPP((userUPP), uppDBQueryDefProcInfo, (sessID), (query))
  269.     #define InvokeDBStatusUPP(message, result, dataLen, dataPlaces, dataFlags, dataType, dataPtr, userUPP)  (Boolean)CALL_SEVEN_PARAMETER_UPP((userUPP), uppDBStatusProcInfo, (message), (result), (dataLen), (dataPlaces), (dataFlags), (dataType), (dataPtr))
  270.     #define InvokeDBResultHandlerUPP(dataType, theLen, thePlaces, theFlags, theData, theText, userUPP)  (OSErr)CALL_SIX_PARAMETER_UPP((userUPP), uppDBResultHandlerProcInfo, (dataType), (theLen), (thePlaces), (theFlags), (theData), (theText))
  271. #endif
  272. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  273. #define NewDBCompletionProc(userRoutine)                         NewDBCompletionUPP(userRoutine)
  274. #define NewDBQueryDefProc(userRoutine)                             NewDBQueryDefUPP(userRoutine)
  275. #define NewDBStatusProc(userRoutine)                             NewDBStatusUPP(userRoutine)
  276. #define NewDBResultHandlerProc(userRoutine)                     NewDBResultHandlerUPP(userRoutine)
  277. #define CallDBCompletionProc(userRoutine, pb)                    InvokeDBCompletionUPP(pb, userRoutine)
  278. #define CallDBQueryDefProc(userRoutine, sessID, query)            InvokeDBQueryDefUPP(sessID, query, userRoutine)
  279. #define CallDBStatusProc(userRoutine, message, result, dataLen, dataPlaces, dataFlags, dataType, dataPtr) InvokeDBStatusUPP(message, result, dataLen, dataPlaces, dataFlags, dataType, dataPtr, userRoutine)
  280. #define CallDBResultHandlerProc(userRoutine, dataType, theLen, thePlaces, theFlags, theData, theText) InvokeDBResultHandlerUPP(dataType, theLen, thePlaces, theFlags, theData, theText, userRoutine)
  281. EXTERN_API( OSErr )
  282. InitDBPack                        (void)                                                        FIVEWORDINLINE(0x3F3C, 0x0004, 0x303C, 0x0100, 0xA82F);
  283.  
  284. EXTERN_API( OSErr )
  285. DBInit                            (long *                    sessID,
  286.                                  ConstStr63Param         ddevName,
  287.                                  ConstStr255Param         host,
  288.                                  ConstStr255Param         user,
  289.                                  ConstStr255Param         passwd,
  290.                                  ConstStr255Param         connStr,
  291.                                  DBAsyncParmBlkPtr         asyncPB)                            THREEWORDINLINE(0x303C, 0x0E02, 0xA82F);
  292.  
  293. EXTERN_API( OSErr )
  294. DBEnd                            (long                     sessID,
  295.                                  DBAsyncParmBlkPtr         asyncPB)                            THREEWORDINLINE(0x303C, 0x0403, 0xA82F);
  296.  
  297. EXTERN_API( OSErr )
  298. DBGetConnInfo                    (long                     sessID,
  299.                                  short                     sessNum,
  300.                                  long *                    returnedID,
  301.                                  long *                    version,
  302.                                  Str63                     ddevName,
  303.                                  Str255                 host,
  304.                                  Str255                 user,
  305.                                  Str255                 network,
  306.                                  Str255                 connStr,
  307.                                  long *                    start,
  308.                                  OSErr *                state,
  309.                                  DBAsyncParmBlkPtr         asyncPB)                            THREEWORDINLINE(0x303C, 0x1704, 0xA82F);
  310.  
  311. EXTERN_API( OSErr )
  312. DBGetSessionNum                    (long                     sessID,
  313.                                  short *                sessNum,
  314.                                  DBAsyncParmBlkPtr         asyncPB)                            THREEWORDINLINE(0x303C, 0x0605, 0xA82F);
  315.  
  316. EXTERN_API( OSErr )
  317. DBSend                            (long                     sessID,
  318.                                  Ptr                     text,
  319.                                  short                     len,
  320.                                  DBAsyncParmBlkPtr         asyncPB)                            THREEWORDINLINE(0x303C, 0x0706, 0xA82F);
  321.  
  322. EXTERN_API( OSErr )
  323. DBSendItem                        (long                     sessID,
  324.                                  DBType                 dataType,
  325.                                  short                     len,
  326.                                  short                     places,
  327.                                  short                     flags,
  328.                                  void *                    buffer,
  329.                                  DBAsyncParmBlkPtr         asyncPB)                            THREEWORDINLINE(0x303C, 0x0B07, 0xA82F);
  330.  
  331. EXTERN_API( OSErr )
  332. DBExec                            (long                     sessID,
  333.                                  DBAsyncParmBlkPtr         asyncPB)                            THREEWORDINLINE(0x303C, 0x0408, 0xA82F);
  334.  
  335. EXTERN_API( OSErr )
  336. DBState                            (long                     sessID,
  337.                                  DBAsyncParmBlkPtr         asyncPB)                            THREEWORDINLINE(0x303C, 0x0409, 0xA82F);
  338.  
  339. EXTERN_API( OSErr )
  340. DBGetErr                        (long                     sessID,
  341.                                  long *                    err1,
  342.                                  long *                    err2,
  343.                                  Str255                 item1,
  344.                                  Str255                 item2,
  345.                                  Str255                 errorMsg,
  346.                                  DBAsyncParmBlkPtr         asyncPB)                            THREEWORDINLINE(0x303C, 0x0E0A, 0xA82F);
  347.  
  348. EXTERN_API( OSErr )
  349. DBBreak                            (long                     sessID,
  350.                                  Boolean                 abort,
  351.                                  DBAsyncParmBlkPtr         asyncPB)                            THREEWORDINLINE(0x303C, 0x050B, 0xA82F);
  352.  
  353. EXTERN_API( OSErr )
  354. DBGetItem                        (long                     sessID,
  355.                                  long                     timeout,
  356.                                  DBType *                dataType,
  357.                                  short *                len,
  358.                                  short *                places,
  359.                                  short *                flags,
  360.                                  void *                    buffer,
  361.                                  DBAsyncParmBlkPtr         asyncPB)                            THREEWORDINLINE(0x303C, 0x100C, 0xA82F);
  362.  
  363. EXTERN_API( OSErr )
  364. DBUnGetItem                        (long                     sessID,
  365.                                  DBAsyncParmBlkPtr         asyncPB)                            THREEWORDINLINE(0x303C, 0x040D, 0xA82F);
  366.  
  367. EXTERN_API( OSErr )
  368. DBKill                            (DBAsyncParmBlkPtr         asyncPB)                            THREEWORDINLINE(0x303C, 0x020E, 0xA82F);
  369.  
  370. EXTERN_API( OSErr )
  371. DBGetNewQuery                    (short                     queryID,
  372.                                  QueryHandle *            query)                                THREEWORDINLINE(0x303C, 0x030F, 0xA82F);
  373.  
  374. EXTERN_API( OSErr )
  375. DBDisposeQuery                    (QueryHandle             query)                                THREEWORDINLINE(0x303C, 0x0210, 0xA82F);
  376.  
  377. EXTERN_API( OSErr )
  378. DBStartQuery                    (long *                    sessID,
  379.                                  QueryHandle             query,
  380.                                  DBStatusUPP             statusProc,
  381.                                  DBAsyncParmBlkPtr         asyncPB)                            THREEWORDINLINE(0x303C, 0x0811, 0xA82F);
  382.  
  383. EXTERN_API( OSErr )
  384. DBGetQueryResults                (long                     sessID,
  385.                                  ResultsRecord *        results,
  386.                                  long                     timeout,
  387.                                  DBStatusUPP             statusProc,
  388.                                  DBAsyncParmBlkPtr         asyncPB)                            THREEWORDINLINE(0x303C, 0x0A12, 0xA82F);
  389.  
  390. EXTERN_API( OSErr )
  391. DBResultsToText                    (ResultsRecord *        results,
  392.                                  Handle *                theText)                            THREEWORDINLINE(0x303C, 0x0413, 0xA82F);
  393.  
  394. EXTERN_API( OSErr )
  395. DBInstallResultHandler            (DBType                 dataType,
  396.                                  DBResultHandlerUPP     theHandler,
  397.                                  Boolean                 isSysHandler)                        THREEWORDINLINE(0x303C, 0x0514, 0xA82F);
  398.  
  399. EXTERN_API( OSErr )
  400. DBRemoveResultHandler            (DBType                 dataType)                            THREEWORDINLINE(0x303C, 0x0215, 0xA82F);
  401.  
  402. EXTERN_API( OSErr )
  403. DBGetResultHandler                (DBType                 dataType,
  404.                                  DBResultHandlerUPP *    theHandler,
  405.                                  Boolean                 getSysHandler)                        THREEWORDINLINE(0x303C, 0x0516, 0xA82F);
  406.  
  407. EXTERN_API( OSErr )
  408. DBIdle                            (void)                                                        THREEWORDINLINE(0x303C, 0x00FF, 0xA82F);
  409.  
  410.  
  411.  
  412.  
  413. #if PRAGMA_STRUCT_ALIGN
  414.     #pragma options align=reset
  415. #elif PRAGMA_STRUCT_PACKPUSH
  416.     #pragma pack(pop)
  417. #elif PRAGMA_STRUCT_PACK
  418.     #pragma pack()
  419. #endif
  420.  
  421. #ifdef PRAGMA_IMPORT_OFF
  422. #pragma import off
  423. #elif PRAGMA_IMPORT
  424. #pragma import reset
  425. #endif
  426.  
  427. #ifdef __cplusplus
  428. }
  429. #endif
  430.  
  431. #endif /* __DATABASEACCESS__ */
  432.  
  433.